<?php
/*
 * Copyright (c) 2011 Todd Brady
 *
 * PS3Theatre is freely distributable under the terms of the MIT license.
 * For details, see the MIT-Liscence web site: http://www.opensource.org/licenses/mit-license.php 
 */

	mysql_connect("localhost", "root", "");
	if(!mysql_select_db("ps3_theatre")){
		 header( 'Location: databaseMissing.php' ) ;
	}
	
	//setup session settings
	session_start();
	
	//first time session started
	if(!isset( $_SESSION['version'] ) ){
		$settingsResult=mysql_query("SELECT s.version, s.move_the FROM tbl_settings s");
		$settingsRow = mysql_fetch_array($settingsResult);
		$dirResult=mysql_query("SELECT d.computer_path, d.http_path FROM tbl_directories d, tbl_types t WHERE d.type_id=t.id AND t.type='Main'");
		if(mysql_num_rows($dirResult)>0){
			$dirRow = mysql_fetch_array($dirResult);
		}
		$version = $settingsRow['version'];
		$moveThe = $settingsRow['move_the'];
		$_SESSION['version'] = $version;
		$_SESSION['moveThe'] = $moveThe;

		if($dirRow != ''){
			$cacheHttpDir = $dirRow['http_path'];
			$cacheCompDir = $dirRow['computer_path'];
			$_SESSION['cacheHttpDir'] = $cacheHttpDir;
			$_SESSION['cacheCompDir'] = $cacheCompDir;
		}
	}
?>